<template>
	<view class="toView">
		<view class="header">
			<image src="../../../static/img/quickly/tcm/tcmTitle@2x.png"></image>
			<view class="information">
				<view class="top">
					<view>会员：{{userInfo.realName || ''}}</view>
					<view>年龄：{{userInfo.age || ''}}岁</view>
					<view>性别：{{userInfo.sex == 1 ? '男' : userInfo.sex == 2 ? '女' : '未知'}}</view>
				</view>
				<view class="bottom">
					<view>签发人：{{data.healthName || ''}}</view>
					<view>签发日期：{{data.modifiedDate}}</view>
				</view>
			</view>
		</view>
		<view class="two"></view>
		<view class="three"></view>
		
		<view class="mainContent">
			<!-- 基本信息 -->
			<view class="informationBox" v-for="(item,index) in appFourDiagnosticEntities" :key="index">
				<view class="boxOne">
					<image mode="widthFix" v-if="index ==0" src="../../../static/img/quickly/tcm/tcmTitle1@2x.png"></image>
					<image mode="widthFix" v-if="index ==1"  src="../../../static/img/quickly/tcm/tcmTitle2@2x.png"></image>
					<image mode="widthFix" v-if="index ==2"  src="../../../static/img/quickly/tcm/tcmTitle3@2x.png"></image>
				</view>
				<view class="boxTwo">
					<view v-for="(aitem,aindex) in item" :key="aindex" class="txt">
						<view>{{aitem.parentName}}:</view>
						<view>{{aitem.name}}</view>
					</view>
				</view>
			</view>
			<view class="informationBox wen">
				<view class="boxOne">
					<image mode="widthFix" src="../../../static/img/quickly/tcm/tcmTitle4@2x.png"></image>
				</view>
				<table borderColor="#ccc" cellspacing="0" cellpadding="0">
					<tr>
						<th>体质类型</th>
						<th>转化分数</th>
						<th>分数对应</th>
					</tr>
					<tr v-for="(item,index) in newAppPhysiqueScoreHealthSort" :key="index">
						<td>{{item.typeName}}</td>
						<td>{{item.healthScore?item.healthScore:item.score}}</td>
						<td>{{item.healthResult?item.healthResult:item.result}}</td>
					</tr>
				</table>
				<div class="info">
					<view>转化人：{{data.userName}}</view>
					<view>转化日期：{{data.createdDate && data.createdDate.substr(0,10)}}</view>
				</div>
				<div class="info">
					<view>确认人：{{data.healthName}}</view>
					<view>确认日期：{{data.modifiedDate}}</view>
				</div>
			</view>
			<view class="btn" @click="jump">查看问卷详情</view>
			<view class="informationBox">
				<view class="boxOne">
					<image mode="widthFix" src="../../../static/img/quickly/tcm/tcmTitle5@2x.png"></image>
				</view>
				<view class="boxTwo">
					<div class="txt" v-if="constitution[0]">
						<view>为：</view>
						<view>{{constitution[0]}}</view>{{constitution[0] == '偏颇体质'?'':'体质'}}
					</div>
					<div class="txt" v-if="constitution[1]">
						<view>以：</view>
						<view>{{constitution[1]}}</view>为主
					</div>
					<div class="txt" v-if="constitution[2]">
						<view>兼：</view>
						<view>{{constitution[2]}}</view>体质
					</div>
					<div class="txt" v-if="constitution[3]">
						<view>有：</view>
						<view>{{constitution[3]}}</view>倾向
					</div>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {getUrlParam,filterData,age} from '@/static/js/filter.js';
	export default {
		data() {
			return {
				userInfo: {},
				data:{},
				appFourDiagnosticEntities:[],
				constitution:[],
				newAppPhysiqueScoreHealthSort:[]
			}
		},
		methods: {
			age,
			jump(){
				localStorage.removeItem('questionData');
				uni.navigateTo({
					url: '/pages/quickly/tcm/questionnaireDetailTCM?editId='+this.data.cid+'&id='+this.data.userId+'&readstatus=1'
				})
			}
		},
		mounted(){
			const _this = this;
			const editId = getUrlParam('id')
			_this.$api.appchinesemedicineexaminationfindById(editId).then((res)=>{
				_this.data = res.data.result.appChineseMedicineExaminationEntityVo;
				const appFourDiagnosticEntities = res.data.result.appChineseMedicineExaminationEntityVo.appFourDiagnosticEntities
				const arr1 = appFourDiagnosticEntities.filter((a)=>{ return a.parentId == 0})
				const arr2 = appFourDiagnosticEntities.filter((a)=>{ return a.parentId == 1})
				const arr3 = appFourDiagnosticEntities.filter((a)=>{ return a.parentId == 2})
				this.appFourDiagnosticEntities = [arr1,arr2,arr3]
				this.constitution = JSON.parse(res.data.result.appChineseMedicineExaminationEntityVo.constitution)
				this.newAppPhysiqueScoreHealthSort = res.data.result.newAppPhysiqueScoreHealthSort.length > 0 ? res.data.result.newAppPhysiqueScoreHealthSort : res.data.result.newAppPhysiqueScoreEntityVos
				_this.$api.findByUserId(res.data.result.appChineseMedicineExaminationEntityVo.userId).then((response)=>{
					_this.userInfo = response.data.result;
					_this.userInfo.age = age('',_this.userInfo.birthday)
				})
			})
			
		},
	}
</script>

<style lang="scss" scoped>
	@import "@/static/css/quickly/tcm/toView.scss" ;
</style>
